﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Exercises
{
    public class Student
    {
        public string FirstName { get; set; }
        public string LastName { get; set; }
        public int Age { get; set; }

        public Student(string first, string last)
        {
            FirstName = first;
            LastName = last;
        }

        public Student(string first, string last, int age)
        {
            FirstName = first;
            LastName = last;
            Age = age;
        }

        public static List<Student> FirstBeforeLast(IEnumerable<Student> students)
        {
            var querryResult = from student in students where student.FirstName.CompareTo(student.LastName) < 0 select student;
            List<Student> result = new List<Student>();
            foreach (var item in querryResult)
            {
                result.Add(item);
            }
            return result;
        }

        public static List<Student> FindByAge(IEnumerable<Student> students)
        {
            var querryResult = from student in students where student.Age >= 4 && student.Age <= 18 select student;
            List<Student> result = new List<Student>();
            foreach (var item in querryResult)
            {
                result.Add(item);
            }
            return result;
        }
    }
}
